﻿#include<iostream>
#include<set>

class person
{
public:
	person(std::string name, int age)
	{
		this->m_Name = name;
		this->m_Age = age;
	}

	std::string m_Name;
	int m_Age;

};
class myCompare
{
public:
	bool operator()(const person p1, const person p2) const
	{
		return p1.m_Age > p2.m_Age;
	}

};
void test01()
{
	std::set<person, myCompare> s1;

	person p1("张三", 23);
	person p2("李四", 20);
	person p3("王五", 18);
	person p4("赵六", 26);
	person p5("黄芪", 29);

	s1.insert(p1);
	s1.insert(p2);
	s1.insert(p3);
	s1.insert(p4);
	s1.insert(p5);

	for (std::set<person, myCompare>::iterator it = s1.begin(); it != s1.end(); ++it)
	{
		std::cout << "姓名：" << it->m_Name << "\t年龄：" << (*it).m_Age << '\n';
	}

}

int main()
{
	test01();

	return 0;
}